<?php

/**
 * alltosun.com 赞 index.php
 * ============================================================================
 * 版权所有 (C) 2009-2014 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 石武浩 (shiwh@alltosun.com) $
 * $Date:  2014-6-19 下午6:26:44 $
 * $Id$
*/

class Action
{
    private $user_id;

    public function __construct()
    {
        $this->user_id = user_helper::get_user_id();
    }

    public function save()
    {
        $res_name = Request::getParam('res_name', '');
        $res_id       = Request::getParam('res_id', 0);

        $info = array();
        $info['res_name'] = $res_name;
        $info['res_id']       = $res_id;
        $info['user_id']     = $this->user_id;

        if (_model('support')->read($info)) {
            return '你已点过赞，不能再次点击';
        }

        _model('support')->create($info);

        $total = support_helper::get_support_total($res_name, $res_id);

        return array('info'=>'ok', 'total'=>$total);
    }
}